//  111111111111

function getUserInfo() {
    $.ajax({
        url: '/my/userinfo',

        headers: {
            Authorization: localStorage.getItem('token') || '',
        },
        success: function(res) {
            console.log(res);
            if (res.data.user_pic === null) {

                var firstWord = (res.data.nickname || res.data.username).charAt(0).toUpperCase()
                $('.test-avatar').html(firstWord).css('visibility', 'visible')
                $('.layui-nav-img').hide()

            } else {
                $('.layui-nav-img').attr('src', res.data.user_pic).show()
                $('.test.avatar').hides()

            }
            $('.welcome').html('欢迎&nbsp;&nbsp;' + (res.data.nickname || res.data.username))

        }

    })
}
getUserInfo()

$('.logout').on('click', function() {
    layer.confirm('是否退出?', { icon: 3, title: '提示' }, function(index) {
        //do something
        localStorage.removeItem('token')
        location.href = '/login.html'
        layer.close(index);
    });

})